Automatically compute upstream version in debian/rules.
authorRob Browning <rlb@defaultvalue.org>
Mon, 8 Apr 2013 01:20:09 +0000 (20:20 -0500)
committerRob Browning <rlb@defaultvalue.org>
Mon, 8 Apr 2013 01:20:09 +0000 (20:20 -0500)
debian/rules
debian/upstream-version [new file with mode: 0755]

index b1601ad6f92c4fce05e08a7557ce831add56af06..7c96f92128d03b4f480dd6602be2dd9bd16fa816 100755 (executable)
@@ -38,7 +38,10 @@ pf := set -o pipefail
 #  builddir.)
 
 # The official upstream version defined by AC_INIT in configure.in.
-upstream_ver := 24.2
+upstream_ver := $(shell debian/upstream-version)
+ifeq (,$(upstream_ver))
+  $(error 'Unable to find upstream version number.')
+endif
 
 # This must be the version that's actually used at runtime for things
 # like load-path.  It may not be the same as the upstream version
diff --git a/debian/upstream-version b/debian/upstream-version
new file mode 100755 (executable)
index 0000000..e54db12
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/perl -w
+
+use strict;
+use English;
+
+open(my $config_file, '<', 'configure.ac')
+    or die "cannot open configure.ac: $!";
+
+my $version = '';
+my $found_init = 0;
+while (<$config_file>)
+{
+  if(/^AC_INIT\(emacs,\s*(\S+)\s*\)$/o)
+  {
+    $found_init and die 'found duplicate AC_INIT() in configure.ac';
+    $version = $1;
+    $found_init = 1;
+  }
+}
+
+$found_init or die 'no AC_INIT() found in configure.ac';
+print "$version\n";